using System;
using System.IO;
using CoreTypes;
using System.Linq;
using System.Custom;
using System.Drawing;
using CustomControls;
using HtmlViewControl;
using System.Collections;
using System.Custom.Window;
using System.Windows.Forms;
using MainModule.Properties;
using System.ComponentModel;
using System.Collections.Generic;

namespace MainModule
{
   internal partial class CommunicatorC : Component
   {
      #region Component Designer generated code

      private void InitializeComponent()
      {
         this.components = new System.ComponentModel.Container();
         System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
         System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CommunicatorC));
         System.Windows.Forms.ToolStripSeparator toolStripSeparator7;
         System.Windows.Forms.ToolStripSeparator toolStripSeparator8;
         System.Windows.Forms.ToolStripSeparator toolStripSeparator5;
         System.Windows.Forms.ToolStripSeparator toolStripSeparator9;
         System.Windows.Forms.ToolStripSeparator toolStripSeparator15;
         System.Windows.Forms.ToolStripSeparator toolStripSeparator6;
         System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
         System.Windows.Forms.ToolStripSeparator toolStripSeparator10;
         System.Windows.Forms.ToolStripSeparator toolStripSeparator13;
         this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator();
         this.toolStripSeparator12 = new System.Windows.Forms.ToolStripSeparator();
         this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
         this.imageListStatus = new System.Windows.Forms.ImageList(this.components);
         this.timerPresence = new System.Windows.Forms.Timer(this.components);
         this.imageListMessage = new System.Windows.Forms.ImageList(this.components);
         this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
         this.menuChatSession = new System.Windows.Forms.ContextMenuStrip(this.components);
         this.itemAddParticipant = new System.Windows.Forms.ToolStripMenuItem();
         this.itemAttachDetachSession = new System.Windows.Forms.ToolStripMenuItem();
         this.itemSessionSettings = new System.Windows.Forms.ToolStripMenuItem();
         this.itemShowStatusEvents = new System.Windows.Forms.ToolStripMenuItem();
         this.itemCloseSession = new System.Windows.Forms.ToolStripMenuItem();
         this.itemFilterUrls = new System.Windows.Forms.ToolStripMenuItem();
         this.itemFilterNumbers = new System.Windows.Forms.ToolStripMenuItem();
         this.menuContact = new System.Windows.Forms.ContextMenuStrip(this.components);
         this.itemChat = new System.Windows.Forms.ToolStripMenuItem();
         this.itemSendFile = new System.Windows.Forms.ToolStripMenuItem();
         this.itemHistory = new System.Windows.Forms.ToolStripMenuItem();
         this.itemCopyContactInfo = new System.Windows.Forms.ToolStripMenuItem();
         this.itemSetCustomName = new System.Windows.Forms.ToolStripMenuItem();
         this.itemContactProperties = new System.Windows.Forms.ToolStripMenuItem();
         this.itemContactPrivacy = new System.Windows.Forms.ToolStripMenuItem();
         this.menuContactPrivacy = new System.Windows.Forms.ContextMenuStrip(this.components);
         this.itemContactVipMode = new System.Windows.Forms.ToolStripMenuItem();
         this.itemVisibilityRuleBlock = new System.Windows.Forms.ToolStripMenuItem();
         this.itemBlockContact = new System.Windows.Forms.ToolStripMenuItem();
         this.itemContactSettings = new System.Windows.Forms.ToolStripMenuItem();
         this.itemRemoveContact = new System.Windows.Forms.ToolStripMenuItem();
         this.menuTextSearch = new System.Windows.Forms.ContextMenuStrip(this.components);
         this.itemFindText = new System.Windows.Forms.ToolStripMenuItem();
         this.itemFilterText = new System.Windows.Forms.ToolStripMenuItem();
         this.itemFilterEmails = new System.Windows.Forms.ToolStripMenuItem();
         this.itemFilterDigits = new System.Windows.Forms.ToolStripMenuItem();
         this.itemResetFilter = new System.Windows.Forms.ToolStripMenuItem();
         this.menuMessage = new System.Windows.Forms.ContextMenuStrip(this.components);
         this.itemReplyMessage = new System.Windows.Forms.ToolStripMenuItem();
         this.itemRepeatMessage = new System.Windows.Forms.ToolStripMenuItem();
         this.itemCancelMessage = new System.Windows.Forms.ToolStripMenuItem();
         this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
         this.itemAcceptInvitation = new System.Windows.Forms.ToolStripMenuItem();
         this.itemDeclineInvitation = new System.Windows.Forms.ToolStripMenuItem();
         this.menuUser = new System.Windows.Forms.ContextMenuStrip(this.components);
         this.itemSendMessage = new System.Windows.Forms.ToolStripMenuItem();
         this.itemAddToContacts = new System.Windows.Forms.ToolStripMenuItem();
         this.itemViewUserInfo = new System.Windows.Forms.ToolStripMenuItem();
         this.menuAccount = new System.Windows.Forms.ContextMenuStrip(this.components);
         this.itemSetupUserpic = new System.Windows.Forms.ToolStripMenuItem();
         this.itemRemoveUserpic = new System.Windows.Forms.ToolStripMenuItem();
         this.itemChangePassword = new System.Windows.Forms.ToolStripMenuItem();
         this.itemAccountPrivacy = new System.Windows.Forms.ToolStripMenuItem();
         this.itemAccountSettings = new System.Windows.Forms.ToolStripMenuItem();
         this.itemAccountEditInfo = new System.Windows.Forms.ToolStripMenuItem();
         this.itemAccountSummary = new System.Windows.Forms.ToolStripMenuItem();
         this.menuContactGroup = new System.Windows.Forms.ContextMenuStrip(this.components);
         this.itemGroupMessage = new System.Windows.Forms.ToolStripMenuItem();
         this.itemRenameGroup = new System.Windows.Forms.ToolStripMenuItem();
         this.itemCreateSubGroup = new System.Windows.Forms.ToolStripMenuItem();
         this.itemRemoveGroup = new System.Windows.Forms.ToolStripMenuItem();
         this.menuHistory = new System.Windows.Forms.ContextMenuStrip(this.components);
         this.itemLastMessages = new System.Windows.Forms.ToolStripMenuItem();
         this.itemPrevPage = new System.Windows.Forms.ToolStripMenuItem();
         this.itemNextPage = new System.Windows.Forms.ToolStripMenuItem();
         this.itemShowPage = new System.Windows.Forms.ToolStripMenuItem();
         this.menuHistoryPages = new System.Windows.Forms.ContextMenuStrip(this.components);
         this.trayControlMain = new CustomControls.TrayAnimation();
         this.trayControlMessage = new CustomControls.TrayAnimation();
         this.timerUpdate = new System.Windows.Forms.Timer(this.components);
         toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
         toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
         toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator();
         toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
         toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator();
         toolStripSeparator15 = new System.Windows.Forms.ToolStripSeparator();
         toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
         toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
         toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator();
         toolStripSeparator13 = new System.Windows.Forms.ToolStripSeparator();
         this.menuChatSession.SuspendLayout();
         this.menuContact.SuspendLayout();
         this.menuContactPrivacy.SuspendLayout();
         this.menuTextSearch.SuspendLayout();
         this.menuMessage.SuspendLayout();
         this.menuUser.SuspendLayout();
         this.menuAccount.SuspendLayout();
         this.menuContactGroup.SuspendLayout();
         this.menuHistory.SuspendLayout();
         this.menuHistoryPages.SuspendLayout();
         // 
         // toolStripSeparator1
         // 
         toolStripSeparator1.Name = "toolStripSeparator1";
         resources.ApplyResources(toolStripSeparator1, "toolStripSeparator1");
         // 
         // toolStripSeparator7
         // 
         toolStripSeparator7.Name = "toolStripSeparator7";
         resources.ApplyResources(toolStripSeparator7, "toolStripSeparator7");
         // 
         // toolStripSeparator8
         // 
         toolStripSeparator8.Name = "toolStripSeparator8";
         resources.ApplyResources(toolStripSeparator8, "toolStripSeparator8");
         // 
         // toolStripSeparator5
         // 
         toolStripSeparator5.Name = "toolStripSeparator5";
         resources.ApplyResources(toolStripSeparator5, "toolStripSeparator5");
         // 
         // toolStripSeparator9
         // 
         toolStripSeparator9.Name = "toolStripSeparator9";
         resources.ApplyResources(toolStripSeparator9, "toolStripSeparator9");
         // 
         // toolStripSeparator15
         // 
         toolStripSeparator15.Name = "toolStripSeparator15";
         resources.ApplyResources(toolStripSeparator15, "toolStripSeparator15");
         // 
         // toolStripSeparator6
         // 
         toolStripSeparator6.Name = "toolStripSeparator6";
         resources.ApplyResources(toolStripSeparator6, "toolStripSeparator6");
         // 
         // toolStripSeparator2
         // 
         toolStripSeparator2.Name = "toolStripSeparator2";
         resources.ApplyResources(toolStripSeparator2, "toolStripSeparator2");
         // 
         // toolStripSeparator10
         // 
         toolStripSeparator10.Name = "toolStripSeparator10";
         resources.ApplyResources(toolStripSeparator10, "toolStripSeparator10");
         // 
         // toolStripSeparator13
         // 
         toolStripSeparator13.Name = "toolStripSeparator13";
         resources.ApplyResources(toolStripSeparator13, "toolStripSeparator13");
         // 
         // toolStripSeparator11
         // 
         this.toolStripSeparator11.Name = "toolStripSeparator11";
         resources.ApplyResources(this.toolStripSeparator11, "toolStripSeparator11");
         // 
         // toolStripSeparator12
         // 
         this.toolStripSeparator12.Name = "toolStripSeparator12";
         resources.ApplyResources(this.toolStripSeparator12, "toolStripSeparator12");
         // 
         // toolStripSeparator3
         // 
         this.toolStripSeparator3.Name = "toolStripSeparator3";
         resources.ApplyResources(this.toolStripSeparator3, "toolStripSeparator3");
         // 
         // imageListStatus
         // 
         this.imageListStatus.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListStatus.ImageStream")));
         this.imageListStatus.TransparentColor = System.Drawing.Color.Transparent;
         this.imageListStatus.Images.SetKeyName(0, "Login");
         this.imageListStatus.Images.SetKeyName(1, "Login");
         this.imageListStatus.Images.SetKeyName(2, "Login");
         this.imageListStatus.Images.SetKeyName(3, "Login");
         this.imageListStatus.Images.SetKeyName(4, "Login");
         this.imageListStatus.Images.SetKeyName(5, "Login");
         this.imageListStatus.Images.SetKeyName(6, "Login");
         this.imageListStatus.Images.SetKeyName(7, "Login");
         // 
         // timerPresence
         // 
         this.timerPresence.Interval = 5000;
         this.timerPresence.Tick += new System.EventHandler(this.timerPresence_Tick);
         // 
         // imageListMessage
         // 
         this.imageListMessage.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListMessage.ImageStream")));
         this.imageListMessage.TransparentColor = System.Drawing.Color.Transparent;
         this.imageListMessage.Images.SetKeyName(0, "NewMessage");
         this.imageListMessage.Images.SetKeyName(1, "ClosedEnvelope");
         this.imageListMessage.Images.SetKeyName(2, "User");
         // 
         // saveFileDialog
         // 
         this.saveFileDialog.FileName = "Profile.xml";
         // 
         // menuChatSession
         // 
         this.menuChatSession.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.itemAddParticipant,
            this.itemAttachDetachSession,
            this.itemSessionSettings,
            this.itemShowStatusEvents,
            toolStripSeparator1,
            this.itemCloseSession});
         this.menuChatSession.Name = "contextMenuSession";
         resources.ApplyResources(this.menuChatSession, "menuChatSession");
         this.menuChatSession.Paint += new System.Windows.Forms.PaintEventHandler(this.menu_Paint);
         this.menuChatSession.Closed += new System.Windows.Forms.ToolStripDropDownClosedEventHandler(this.menu_Closed);
         this.menuChatSession.Opening += new System.ComponentModel.CancelEventHandler(this.menu_Opening);
         // 
         // itemAddParticipant
         // 
         this.itemAddParticipant.Image = global::MainModule.Properties.Resources.Plus_16;
         resources.ApplyResources(this.itemAddParticipant, "itemAddParticipant");
         this.itemAddParticipant.Name = "itemAddParticipant";
         // 
         // itemAttachDetachSession
         // 
         this.itemAttachDetachSession.Name = "itemAttachDetachSession";
         resources.ApplyResources(this.itemAttachDetachSession, "itemAttachDetachSession");
         // 
         // itemSessionSettings
         // 
         resources.ApplyResources(this.itemSessionSettings, "itemSessionSettings");
         this.itemSessionSettings.Name = "itemSessionSettings";
         // 
         // itemShowStatusEvents
         // 
         this.itemShowStatusEvents.Image = global::MainModule.Properties.Resources.RedLightning_16;
         resources.ApplyResources(this.itemShowStatusEvents, "itemShowStatusEvents");
         this.itemShowStatusEvents.Name = "itemShowStatusEvents";
         // 
         // itemCloseSession
         // 
         this.itemCloseSession.Image = global::MainModule.Properties.Resources.CloseChromeGrayMiddle;
         resources.ApplyResources(this.itemCloseSession, "itemCloseSession");
         this.itemCloseSession.Name = "itemCloseSession";
         // 
         // itemFilterUrls
         // 
         this.itemFilterUrls.Image = global::MainModule.Properties.Resources.Globe16;
         resources.ApplyResources(this.itemFilterUrls, "itemFilterUrls");
         this.itemFilterUrls.Name = "itemFilterUrls";
         // 
         // itemFilterNumbers
         // 
         this.itemFilterNumbers.Name = "itemFilterNumbers";
         resources.ApplyResources(this.itemFilterNumbers, "itemFilterNumbers");
         // 
         // menuContact
         // 
         this.menuContact.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.itemChat,
            this.itemSendFile,
            this.itemHistory,
            this.toolStripSeparator3,
            this.itemCopyContactInfo,
            this.itemSetCustomName,
            this.itemContactProperties,
            toolStripSeparator7,
            this.itemContactPrivacy,
            this.itemRemoveContact});
         this.menuContact.Name = "contextMenuContact";
         resources.ApplyResources(this.menuContact, "menuContact");
         this.menuContact.Paint += new System.Windows.Forms.PaintEventHandler(this.menu_Paint);
         this.menuContact.Closed += new System.Windows.Forms.ToolStripDropDownClosedEventHandler(this.menu_Closed);
         this.menuContact.Opening += new System.ComponentModel.CancelEventHandler(this.menu_Opening);
         // 
         // itemChat
         // 
         this.itemChat.Image = global::MainModule.Properties.Resources.OdnoklPostBlue;
         resources.ApplyResources(this.itemChat, "itemChat");
         this.itemChat.Name = "itemChat";
         // 
         // itemSendFile
         // 
         this.itemSendFile.Name = "itemSendFile";
         resources.ApplyResources(this.itemSendFile, "itemSendFile");
         // 
         // itemHistory
         // 
         this.itemHistory.Image = global::MainModule.Properties.Resources.HistoryFolder16_S;
         resources.ApplyResources(this.itemHistory, "itemHistory");
         this.itemHistory.Name = "itemHistory";
         // 
         // itemCopyContactInfo
         // 
         this.itemCopyContactInfo.Name = "itemCopyContactInfo";
         resources.ApplyResources(this.itemCopyContactInfo, "itemCopyContactInfo");
         // 
         // itemSetCustomName
         // 
         this.itemSetCustomName.Name = "itemSetCustomName";
         resources.ApplyResources(this.itemSetCustomName, "itemSetCustomName");
         // 
         // itemContactProperties
         // 
         this.itemContactProperties.Image = global::MainModule.Properties.Resources.Info_16;
         resources.ApplyResources(this.itemContactProperties, "itemContactProperties");
         this.itemContactProperties.Name = "itemContactProperties";
         // 
         // itemContactPrivacy
         // 
         this.itemContactPrivacy.DropDown = this.menuContactPrivacy;
         resources.ApplyResources(this.itemContactPrivacy, "itemContactPrivacy");
         this.itemContactPrivacy.Name = "itemContactPrivacy";
         // 
         // menuContactPrivacy
         // 
         this.menuContactPrivacy.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.itemContactVipMode,
            this.itemVisibilityRuleBlock,
            this.itemBlockContact,
            toolStripSeparator8,
            this.itemContactSettings});
         this.menuContactPrivacy.Name = "contextMenuContact";
         this.menuContactPrivacy.OwnerItem = this.itemContactPrivacy;
         resources.ApplyResources(this.menuContactPrivacy, "menuContactPrivacy");
         this.menuContactPrivacy.Paint += new System.Windows.Forms.PaintEventHandler(this.menu_Paint);
         this.menuContactPrivacy.Closed += new System.Windows.Forms.ToolStripDropDownClosedEventHandler(this.menu_Closed);
         this.menuContactPrivacy.Opening += new System.ComponentModel.CancelEventHandler(this.menu_Opening);
         // 
         // itemContactVipMode
         // 
         this.itemContactVipMode.Image = global::MainModule.Properties.Resources.Favourite_S_16;
         resources.ApplyResources(this.itemContactVipMode, "itemContactVipMode");
         this.itemContactVipMode.Name = "itemContactVipMode";
         // 
         // itemVisibilityRuleBlock
         // 
         this.itemVisibilityRuleBlock.Name = "itemVisibilityRuleBlock";
         resources.ApplyResources(this.itemVisibilityRuleBlock, "itemVisibilityRuleBlock");
         // 
         // itemBlockContact
         // 
         this.itemBlockContact.Image = global::MainModule.Properties.Resources.Deny_16_14;
         resources.ApplyResources(this.itemBlockContact, "itemBlockContact");
         this.itemBlockContact.Name = "itemBlockContact";
         // 
         // itemContactSettings
         // 
         this.itemContactSettings.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
         this.itemContactSettings.Image = global::MainModule.Properties.Resources.Protection;
         resources.ApplyResources(this.itemContactSettings, "itemContactSettings");
         this.itemContactSettings.Name = "itemContactSettings";
         // 
         // itemRemoveContact
         // 
         this.itemRemoveContact.Image = global::MainModule.Properties.Resources.Delete_S;
         resources.ApplyResources(this.itemRemoveContact, "itemRemoveContact");
         this.itemRemoveContact.Name = "itemRemoveContact";
         // 
         // menuTextSearch
         // 
         this.menuTextSearch.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.itemFindText,
            toolStripSeparator2,
            this.itemFilterText,
            this.itemFilterUrls,
            this.itemFilterEmails,
            this.itemFilterDigits,
            this.itemFilterNumbers,
            toolStripSeparator10,
            this.itemResetFilter});
         this.menuTextSearch.Name = "menuTextSearch";
         this.menuTextSearch.ShowItemToolTips = false;
         resources.ApplyResources(this.menuTextSearch, "menuTextSearch");
         this.menuTextSearch.Paint += new System.Windows.Forms.PaintEventHandler(this.menu_Paint);
         this.menuTextSearch.Opening += new System.ComponentModel.CancelEventHandler(this.menu_Opening);
         // 
         // itemFindText
         // 
         resources.ApplyResources(this.itemFindText, "itemFindText");
         this.itemFindText.Name = "itemFindText";
         // 
         // itemFilterText
         // 
         this.itemFilterText.Name = "itemFilterText";
         resources.ApplyResources(this.itemFilterText, "itemFilterText");
         // 
         // itemFilterEmails
         // 
         this.itemFilterEmails.Name = "itemFilterEmails";
         resources.ApplyResources(this.itemFilterEmails, "itemFilterEmails");
         // 
         // itemFilterDigits
         // 
         this.itemFilterDigits.Name = "itemFilterDigits";
         resources.ApplyResources(this.itemFilterDigits, "itemFilterDigits");
         // 
         // itemResetFilter
         // 
         this.itemResetFilter.Name = "itemResetFilter";
         resources.ApplyResources(this.itemResetFilter, "itemResetFilter");
         // 
         // menuMessage
         // 
         this.menuMessage.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.itemReplyMessage,
            this.itemRepeatMessage,
            this.itemCancelMessage,
            this.toolStripSeparator4,
            this.itemAcceptInvitation,
            this.itemDeclineInvitation});
         this.menuMessage.Name = "contextMenuMessage";
         resources.ApplyResources(this.menuMessage, "menuMessage");
         this.menuMessage.Paint += new System.Windows.Forms.PaintEventHandler(this.menu_Paint);
         this.menuMessage.Opening += new System.ComponentModel.CancelEventHandler(this.menu_Opening);
         // 
         // itemReplyMessage
         // 
         this.itemReplyMessage.Name = "itemReplyMessage";
         resources.ApplyResources(this.itemReplyMessage, "itemReplyMessage");
         // 
         // itemRepeatMessage
         // 
         this.itemRepeatMessage.Image = global::MainModule.Properties.Resources.RepeatHS;
         resources.ApplyResources(this.itemRepeatMessage, "itemRepeatMessage");
         this.itemRepeatMessage.Name = "itemRepeatMessage";
         // 
         // itemCancelMessage
         // 
         this.itemCancelMessage.Image = global::MainModule.Properties.Resources.Close_14;
         resources.ApplyResources(this.itemCancelMessage, "itemCancelMessage");
         this.itemCancelMessage.Name = "itemCancelMessage";
         // 
         // toolStripSeparator4
         // 
         this.toolStripSeparator4.Name = "toolStripSeparator4";
         resources.ApplyResources(this.toolStripSeparator4, "toolStripSeparator4");
         // 
         // itemAcceptInvitation
         // 
         this.itemAcceptInvitation.Image = global::MainModule.Properties.Resources.GreenCheck_16;
         resources.ApplyResources(this.itemAcceptInvitation, "itemAcceptInvitation");
         this.itemAcceptInvitation.Name = "itemAcceptInvitation";
         // 
         // itemDeclineInvitation
         // 
         this.itemDeclineInvitation.Image = global::MainModule.Properties.Resources.Minus_16;
         resources.ApplyResources(this.itemDeclineInvitation, "itemDeclineInvitation");
         this.itemDeclineInvitation.Name = "itemDeclineInvitation";
         // 
         // menuUser
         // 
         this.menuUser.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.itemSendMessage,
            this.itemAddToContacts,
            toolStripSeparator5,
            this.itemViewUserInfo});
         this.menuUser.Name = "contextMenuStrip";
         resources.ApplyResources(this.menuUser, "menuUser");
         this.menuUser.Paint += new System.Windows.Forms.PaintEventHandler(this.menu_Paint);
         this.menuUser.Opening += new System.ComponentModel.CancelEventHandler(this.menu_Opening);
         // 
         // itemSendMessage
         // 
         this.itemSendMessage.Image = global::MainModule.Properties.Resources.Chat2_16;
         resources.ApplyResources(this.itemSendMessage, "itemSendMessage");
         this.itemSendMessage.Name = "itemSendMessage";
         // 
         // itemAddToContacts
         // 
         this.itemAddToContacts.Image = global::MainModule.Properties.Resources.Plus2_S16;
         resources.ApplyResources(this.itemAddToContacts, "itemAddToContacts");
         this.itemAddToContacts.Name = "itemAddToContacts";
         // 
         // itemViewUserInfo
         // 
         this.itemViewUserInfo.Image = global::MainModule.Properties.Resources.Info_16;
         resources.ApplyResources(this.itemViewUserInfo, "itemViewUserInfo");
         this.itemViewUserInfo.Name = "itemViewUserInfo";
         // 
         // menuAccount
         // 
         this.menuAccount.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.itemSetupUserpic,
            this.itemRemoveUserpic,
            toolStripSeparator9,
            this.itemChangePassword,
            this.itemAccountPrivacy,
            this.itemAccountSettings,
            this.itemAccountEditInfo,
            toolStripSeparator15,
            this.itemAccountSummary});
         this.menuAccount.Name = "menuAccount";
         resources.ApplyResources(this.menuAccount, "menuAccount");
         this.menuAccount.Paint += new System.Windows.Forms.PaintEventHandler(this.menu_Paint);
         this.menuAccount.Opening += new System.ComponentModel.CancelEventHandler(this.menu_Opening);
         // 
         // itemSetupUserpic
         // 
         resources.ApplyResources(this.itemSetupUserpic, "itemSetupUserpic");
         this.itemSetupUserpic.Name = "itemSetupUserpic";
         // 
         // itemRemoveUserpic
         // 
         this.itemRemoveUserpic.Name = "itemRemoveUserpic";
         resources.ApplyResources(this.itemRemoveUserpic, "itemRemoveUserpic");
         // 
         // itemChangePassword
         // 
         resources.ApplyResources(this.itemChangePassword, "itemChangePassword");
         this.itemChangePassword.Name = "itemChangePassword";
         // 
         // itemAccountPrivacy
         // 
         this.itemAccountPrivacy.Image = global::MainModule.Properties.Resources.Uac_16;
         this.itemAccountPrivacy.Name = "itemAccountPrivacy";
         resources.ApplyResources(this.itemAccountPrivacy, "itemAccountPrivacy");
         // 
         // itemAccountSettings
         // 
         this.itemAccountSettings.Name = "itemAccountSettings";
         resources.ApplyResources(this.itemAccountSettings, "itemAccountSettings");
         // 
         // itemAccountEditInfo
         // 
         resources.ApplyResources(this.itemAccountEditInfo, "itemAccountEditInfo");
         this.itemAccountEditInfo.Name = "itemAccountEditInfo";
         // 
         // itemAccountSummary
         // 
         this.itemAccountSummary.Image = global::MainModule.Properties.Resources.Info_16;
         this.itemAccountSummary.Name = "itemAccountSummary";
         resources.ApplyResources(this.itemAccountSummary, "itemAccountSummary");
         // 
         // menuContactGroup
         // 
         this.menuContactGroup.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.itemGroupMessage,
            toolStripSeparator6,
            this.itemRenameGroup,
            this.itemCreateSubGroup,
            this.itemRemoveGroup});
         this.menuContactGroup.Name = "contextMenuContact";
         resources.ApplyResources(this.menuContactGroup, "menuContactGroup");
         this.menuContactGroup.Paint += new System.Windows.Forms.PaintEventHandler(this.menu_Paint);
         this.menuContactGroup.Opening += new System.ComponentModel.CancelEventHandler(this.menu_Opening);
         // 
         // itemGroupMessage
         // 
         resources.ApplyResources(this.itemGroupMessage, "itemGroupMessage");
         this.itemGroupMessage.Image = global::MainModule.Properties.Resources.OdnoklPostBlue;
         this.itemGroupMessage.Name = "itemGroupMessage";
         // 
         // itemRenameGroup
         // 
         this.itemRenameGroup.Name = "itemRenameGroup";
         resources.ApplyResources(this.itemRenameGroup, "itemRenameGroup");
         // 
         // itemCreateSubGroup
         // 
         resources.ApplyResources(this.itemCreateSubGroup, "itemCreateSubGroup");
         this.itemCreateSubGroup.Name = "itemCreateSubGroup";
         // 
         // itemRemoveGroup
         // 
         this.itemRemoveGroup.Image = global::MainModule.Properties.Resources.Delete_S;
         resources.ApplyResources(this.itemRemoveGroup, "itemRemoveGroup");
         this.itemRemoveGroup.Name = "itemRemoveGroup";
         // 
         // menuHistory
         // 
         this.menuHistory.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.itemLastMessages,
            this.toolStripSeparator11,
            this.itemPrevPage,
            this.itemNextPage,
            this.toolStripSeparator12,
            this.itemShowPage});
         this.menuHistory.Name = "menuHistory";
         resources.ApplyResources(this.menuHistory, "menuHistory");
         this.menuHistory.Paint += new System.Windows.Forms.PaintEventHandler(this.menu_Paint);
         this.menuHistory.Opening += new System.ComponentModel.CancelEventHandler(this.menu_Opening);
         // 
         // itemLastMessages
         // 
         this.itemLastMessages.Name = "itemLastMessages";
         resources.ApplyResources(this.itemLastMessages, "itemLastMessages");
         // 
         // itemPrevPage
         // 
         this.itemPrevPage.Name = "itemPrevPage";
         resources.ApplyResources(this.itemPrevPage, "itemPrevPage");
         // 
         // itemNextPage
         // 
         this.itemNextPage.Name = "itemNextPage";
         resources.ApplyResources(this.itemNextPage, "itemNextPage");
         // 
         // itemShowPage
         // 
         this.itemShowPage.DropDown = this.menuHistoryPages;
         this.itemShowPage.Name = "itemShowPage";
         resources.ApplyResources(this.itemShowPage, "itemShowPage");
         // 
         // menuHistoryPages
         // 
         this.menuHistoryPages.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            toolStripSeparator13});
         this.menuHistoryPages.Name = "menuHistoryPages";
         this.menuHistoryPages.OwnerItem = this.itemShowPage;
         resources.ApplyResources(this.menuHistoryPages, "menuHistoryPages");
         this.menuHistoryPages.Paint += new System.Windows.Forms.PaintEventHandler(this.menu_Paint);
         this.menuHistoryPages.Opening += new System.ComponentModel.CancelEventHandler(this.menu_Opening);
         // 
         // trayControlMain
         // 
         this.trayControlMain.Enabled = true;
         this.trayControlMain.Menu = null;
         this.trayControlMain.ParentControl = null;
         this.trayControlMain.Tag = null;
         this.trayControlMain.Tip = "";
         this.trayControlMain.Visible = false;
         this.trayControlMain.BalloonClick += new System.EventHandler(this.trayControlMain_BalloonClick);
         this.trayControlMain.MouseClick += new System.Windows.Forms.MouseEventHandler(this.trayControlMain_MouseClick);
         // 
         // trayControlMessage
         // 
         this.trayControlMessage.Enabled = true;
         this.trayControlMessage.Menu = null;
         this.trayControlMessage.ParentControl = null;
         this.trayControlMessage.Tag = null;
         this.trayControlMessage.Tip = "";
         this.trayControlMessage.Visible = false;
         this.trayControlMessage.BalloonClick += new System.EventHandler(this.trayControlMessage_BalloonClick);
         this.trayControlMessage.BalloonHide += new System.EventHandler(this.trayControlMessage_BalloonHide);
         this.trayControlMessage.MouseClick += new System.Windows.Forms.MouseEventHandler(this.trayControlMessage_MouseClick);
         // 
         // timerUpdate
         // 
         this.timerUpdate.Enabled = true;
         this.timerUpdate.Interval = 7200000;
         this.timerUpdate.Tick += new System.EventHandler(this.timerUpdate_Tick);
         this.menuChatSession.ResumeLayout(false);
         this.menuContact.ResumeLayout(false);
         this.menuContactPrivacy.ResumeLayout(false);
         this.menuTextSearch.ResumeLayout(false);
         this.menuMessage.ResumeLayout(false);
         this.menuUser.ResumeLayout(false);
         this.menuAccount.ResumeLayout(false);
         this.menuContactGroup.ResumeLayout(false);
         this.menuHistory.ResumeLayout(false);
         this.menuHistoryPages.ResumeLayout(false);

      }
      protected override void Dispose(bool disposing)
      {
         if (disposing && (components != null))
         {
            components.Dispose();
         }
         base.Dispose(disposing);
      }

      private System.ComponentModel.IContainer components = null;
      internal System.Windows.Forms.Timer timerPresence;
      internal CustomControls.TrayAnimation trayControlMain;
      internal CustomControls.TrayAnimation trayControlMessage;
      internal ImageList imageListStatus;
      internal SaveFileDialog saveFileDialog;
      internal ContextMenuStrip menuChatSession;
      private ToolStripMenuItem itemAddParticipant;
      private ToolStripMenuItem itemFilterUrls;
      private ToolStripMenuItem itemCloseSession;
      private ToolStripMenuItem itemSessionSettings;
      internal ContextMenuStrip menuContact;
      private ToolStripMenuItem itemChat;
      private ToolStripMenuItem itemHistory;
      private ToolStripMenuItem itemContactPrivacy;
      private ToolStripMenuItem itemRemoveContact;
      private ToolStripMenuItem itemContactProperties;
      internal ContextMenuStrip menuMessage;
      private ToolStripMenuItem itemDeclineInvitation;
      private ToolStripMenuItem itemAcceptInvitation;
      private ToolStripMenuItem itemRepeatMessage;
      private ToolStripMenuItem itemCancelMessage;
      private ToolStripMenuItem itemFilterNumbers;
      private ToolStripMenuItem itemShowStatusEvents;
      private ToolStripMenuItem itemSendFile;
      internal ContextMenuStrip menuUser;
      private ToolStripMenuItem itemSendMessage;
      private ToolStripMenuItem itemAddToContacts;
      private ToolStripMenuItem itemViewUserInfo;
      internal ContextMenuStrip menuAccount;
      private ToolStripMenuItem itemSetupUserpic;
      private ToolStripMenuItem itemChangePassword;
      private ToolStripMenuItem itemAccountEditInfo;
      private ToolStripMenuItem itemRemoveUserpic;
      private ToolStripMenuItem itemReplyMessage;
      internal ContextMenuStrip menuContactGroup;
      private ToolStripMenuItem itemGroupMessage;
      private ToolStripMenuItem itemCreateSubGroup;
      private ToolStripMenuItem itemRemoveGroup;
      private ToolStripMenuItem itemSetCustomName;
      internal ContextMenuStrip menuContactPrivacy;
      private ToolStripMenuItem itemVisibilityRuleBlock;
      private ToolStripMenuItem itemBlockContact;
      private ToolStripMenuItem itemContactVipMode;
      private ToolStripMenuItem itemContactSettings;
      private ToolStripMenuItem itemCopyContactInfo;
      private ToolStripMenuItem itemAccountPrivacy;
      private ToolStripMenuItem itemAccountSettings;
      private ToolStripMenuItem itemAccountSummary;
      internal ImageList imageListMessage;
      private ToolStripMenuItem itemAttachDetachSession;
      private ToolStripMenuItem itemRenameGroup;
      internal ContextMenuStrip menuTextSearch;
      private ToolStripMenuItem itemFindText;
      private ToolStripSeparator toolStripSeparator3;
      private ToolStripMenuItem itemFilterEmails;
      private ToolStripMenuItem itemFilterText;
      private ToolStripMenuItem itemResetFilter;
      private ToolStripMenuItem itemFilterDigits;
      internal ContextMenuStrip menuHistory;
      private ToolStripMenuItem itemPrevPage;
      private ToolStripMenuItem itemShowPage;
      private ToolStripMenuItem itemLastMessages;
      private ToolStripMenuItem itemNextPage;
      internal ContextMenuStrip menuHistoryPages;
      private ToolStripSeparator toolStripSeparator4;
      internal ContextMenuStrip menuEmoticons;
      private ToolStripSeparator toolStripSeparator11;
      private ToolStripSeparator toolStripSeparator12;
      private Timer timerUpdate;

      #endregion

      InternetCommunicator FCommunicator = InternetCommunicator.Self;

      public CommunicatorC()
      {
         InitializeComponent();

         menuEmoticons = new System.Windows.Forms.ContextMenuStrip(this.components);
         menuEmoticons.Name = "menuEmoticons";
         menuEmoticons.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
         menuEmoticons.Paint += new System.Windows.Forms.PaintEventHandler(menu_Paint);
         menuEmoticons.Opening += new System.ComponentModel.CancelEventHandler(menu_Opening);
        
         // Adding empty images for "blink" animation
         Bitmap b = new Bitmap(16, 16);
         foreach (string k in imageListMessage.Images.Keys) imageListMessage.Images.Add(k, b);

         trayControlMain.AnimationSequences = imageListStatus;
         trayControlMessage.AnimationSequences = imageListMessage;

         menuAccount.Opening += menuAccount_Opening;
         menuContact.Opening += menuContact_Opening;
         menuMessage.Opening += menuMessage_Opening;
         menuHistory.Opening += menuHistory_Opening;
         menuTextSearch.Opening += menuTextSearch_Opening;
         menuChatSession.Opening += menuChatSession_Opening;
         menuHistoryPages.Opening += menuHistoryPages_Opening;
         menuContactGroup.Opening += menuContactGroup_Opening;
         menuContactPrivacy.Opening += menuContactPrivacy_Opening;

         itemSetupUserpic.Click += itemSetupUserpic_Click;
         itemRemoveUserpic.Click += itemResetUserpic_Click;
         itemChangePassword.Click += itemChangePassword_Click;
         itemAccountPrivacy.Click += itemAccountPrivacy_Click;
         itemAccountSettings.Click += itemAccountSettings_Click;
         itemAccountEditInfo.Click += itemAccountEditInfo_Click;
         itemAccountSummary.Click += itemAccountSummary_Click;

         itemAddParticipant.Click += itemAddParticipant_Click;
         itemSessionSettings.Click += itemSessionProperties_Click;
         itemCloseSession.Click += itemCloseSession_Click;
         itemShowStatusEvents.Click += itemShowStatusEvents_Click;
         itemAttachDetachSession.Click += itemAttachDetachSession_Click;

         itemLastMessages.Click += itemShowPage_Click;
         itemPrevPage.Click += itemShowPage_Click;
         itemNextPage.Click += itemShowPage_Click;
         
         itemFilterText.Click += itemFindText_Click;
         itemFilterUrls.Click += itemFilterUrls_Click;
         itemFilterEmails.Click += itemFilterEmails_Click;
         itemFilterDigits.Click += itemFilterDigits_Click;
         itemFilterNumbers.Click += itemFilterNumbers_Click;
         itemResetFilter.Click += itemResetFilter_Click;
         itemFindText.Click += itemFindText_Click;
        
         itemChat.Click += itemOpenChat_Click;
         itemHistory.Click += itemHistory_Click;
         itemRemoveContact.Click += itemRemoveContact_Click;
         itemSetCustomName.Click += itemSetCustomName_Click;
         itemCopyContactInfo.Click += itemCopyContactInfo_Click;
         itemContactSettings.Click += itemContactSettings_Click;
         itemContactProperties.Click += itemContactProperties_Click;
         
         itemReplyMessage.Click += itemReplyMessage_Click;
         itemRepeatMessage.Click += itemRepeatMessage_Click;
         itemDeclineInvitation.Click += itemDeclineInvitation_Click;
         itemAcceptInvitation.Click += itemAcceptInvitation_Click;

         itemGroupMessage.Click += itemGroupMessage_Click;
         itemRemoveGroup.Click += itemRemoveGroup_Click;
         itemCreateSubGroup.Click += itemCreateSubGroup_Click;
         itemRenameGroup.Click += itemRenameGroup_Click;

         itemBlockContact.Click += itemBlockContact_Click;
         itemContactVipMode.Click += itemContactVipMode_Click;
         itemVisibilityRuleBlock.Click += itemVisibilityRuleBlock_Click;

         itemAddToContacts.Click += itemAddToContacts_Click;
         itemSendMessage.Click += itemSendMessage_Click;
         itemViewUserInfo.Click += itemViewUserInfo_Click;
      }

      private ChatSession CurrentChat
      {
         get
         {
            return FCommunicator.ActiveMediaWindow.ActiveMediaSession as ChatSession;
         }
      }
      internal void PrepareMenuContact(Contact contact)
      {
         bool visible = menuContact == null || menuContact.OwnerItem == null ||
                        menuContact.OwnerItem is ToolStripMenuItem && !(menuContact.OwnerItem.Owner is MenuStrip);
         
         itemChat.Visible = visible;
         itemHistory.Visible = visible;
         toolStripSeparator3.Visible = visible;

         menuContact.Tag = contact;
         menuContactPrivacy.Tag = contact;
         itemContactProperties.Text = Resources.S_Properties_of_user.Replace("<user>", contact.CustomName) + "...";
      }

      internal void menu_Paint(object sender, PaintEventArgs e)
      {
         FCommunicator.DrawTheme(FCommunicator.ColorTheme, e.Graphics, (sender as Control).ClientRectangle, sender == menuEmoticons ? ColorThemeObject.AppMenu : ColorThemeObject.Menu);
      }
      internal void menu_Opening(object sender, CancelEventArgs e)
      {
         MenuWrapper.MakeFadeEffect((ContextMenuStrip)sender, FCommunicator.MaxMenuOpacity);
      }
      private void menu_Closed(object sender, ToolStripDropDownClosedEventArgs e)
      {
         ContextMenuStrip menu = (ContextMenuStrip)sender;
         // Call async because menuItem.Click occures AFTER menu.Closed
         menu.BeginInvoke(new Action(() => { if (!menu.Visible) menu.Tag = null; }));
      }

      private void menuAccount_Opening(object sender, CancelEventArgs e)
      {
         menuAccount.Tag = FCommunicator.CurrentAccount;

         itemChangePassword.Visible = FCommunicator.CurrentAccount.ServiceConfig.SupportsAction(ServiceActions.PASSWORD) &&
                                     !FCommunicator.CurrentAccount.ServiceConfig.AuthCurrentUser;
      }
      private void menuContact_Opening(object sender, CancelEventArgs e)
      {
         if (menuContact.OwnerItem != null /* from menu */) PrepareMenuContact(CurrentChat.Interlocutor);
      }
      private void menuMessage_Opening(object sender, CancelEventArgs e)
      {
         ServiceMessage message = menuMessage.Tag as ServiceMessage;

         if (message != null)
         {
            if (message is SessionInvitation)
            {
               SessionInvitation invitation = message as SessionInvitation;

               itemCancelMessage.Enabled = true;
               itemDeclineInvitation.Enabled = invitation.IsIncoming && invitation.IsExpired == false;
               itemAcceptInvitation.Enabled = invitation.IsIncoming && invitation.IsExpired == false;
               itemCancelMessage.Visible = invitation.IsOutgoing && invitation.IsExpired == false;
               itemDeclineInvitation.Visible = invitation.IsIncoming;
               itemAcceptInvitation.Visible = invitation.IsIncoming;
               itemRepeatMessage.Visible = invitation.IsOutgoing;
               itemReplyMessage.Visible = false;
            }
            else if (message is ChatMessage)
            {
               ChatMessage chatMessage = message as ChatMessage;

               itemCancelMessage.Enabled = false;
               itemCancelMessage.Visible = chatMessage.IsOutgoing && !chatMessage.IsRead && false;
               itemDeclineInvitation.Visible = false;
               itemAcceptInvitation.Visible = false;
               itemRepeatMessage.Visible = true;
               itemReplyMessage.Visible = chatMessage.IsIncoming;
            }
            else
            {
               itemCancelMessage.Visible = false;
               itemDeclineInvitation.Visible = false;
               itemAcceptInvitation.Visible = false;
               itemRepeatMessage.Visible = false;
               itemReplyMessage.Visible = false;
            }
         }
         else
         {
            e.Cancel = true;
         }
      }
      private void menuChatSession_Opening(object sender, CancelEventArgs e)
      {
         if (menuChatSession.OwnerItem != null /* from menu */) menuChatSession.Tag = CurrentChat;

         ChatSession session = menuChatSession.Tag as ChatSession;

         itemShowStatusEvents.Checked = session.ChatControl.ShowStatusEvents;
         itemSessionSettings.Visible = !session.IsPersonal;
         itemAttachDetachSession.Text = session.Visualizer.MediaWindow.ExclusiveSessionMode ?
                                        Resources.S_In_common_window : Resources.S_In_separate_window;
      }
      private void menuHistory_Opening(object sender, CancelEventArgs e)
      {
         Dictionary<int, string> dict = FCommunicator.EventLog.GetFilesNames(CurrentChat.Interlocutor, DateTime.MinValue, DateTime.MaxValue);

         menuHistoryPages.Tag = dict;

         if (dict.Count == 0)
         {
            itemLastMessages.Enabled = false;
            toolStripSeparator11.Visible = false;
            itemPrevPage.Visible = false;
            itemNextPage.Visible = false;
            toolStripSeparator12.Visible = false;
            itemShowPage.Visible = false;
         }
         else
         {
            itemLastMessages.Enabled = true;
            toolStripSeparator11.Visible = true;
            itemPrevPage.Visible = true;
            itemNextPage.Visible = true;
            toolStripSeparator12.Visible = true;
            itemShowPage.Visible = true;
         }

         if (CurrentChat.ChatControl.CurrentPageTrimmed)
         {
            itemPrevPage.Visible = false;
            itemNextPage.Text = Resources.S_Show_full_page;
         }
         else
         {
            itemPrevPage.Visible = true;
            itemNextPage.Text = Resources.S_Next_page;
         }
      }
      private void menuTextSearch_Opening(object sender, CancelEventArgs e)
      {
         ChatSession session = CurrentChat;

         itemFilterText.Checked = session.ChatControl.FilteredSearch;
         itemFilterUrls.Checked = session.ChatControl.ContentFilter == TextDataTypes.Url;
         itemFilterEmails.Checked = session.ChatControl.ContentFilter == TextDataTypes.Email;
         itemFilterDigits.Checked = session.ChatControl.ContentFilter == TextDataTypes.Digit;
         itemFilterNumbers.Checked = session.ChatControl.ContentFilter == (TextDataTypes.Number | TextDataTypes.Phone);
      }
      private void menuHistoryPages_Opening(object sender, CancelEventArgs e)
      {
         menuHistoryPages.Items.Clear();

         Dictionary<int, string> dict =
            menuHistory.Visible && (menuHistoryPages.Tag is Dictionary<int, string>) ?
            menuHistoryPages.Tag as Dictionary<int, string> :
            FCommunicator.EventLog.GetFilesNames(CurrentChat.Interlocutor, DateTime.MinValue, DateTime.MaxValue);

         menuHistoryPages.Tag = null;

         if (dict.Count == 0)
         {
            e.Cancel = true;
            return;
         }

         var namePairs = dict.OrderByDescending(pair => pair.Key);

         foreach (var file in namePairs)
         {
            FileInfo fi = new FileInfo(FCommunicator.EventLog.LogsDir + file.Value);

            ToolStripMenuItem item = new ToolStripMenuItem();

            string wts = fi.LastWriteTime.ToString("MMMM yyyy");
            string cts = fi.CreationTime < fi.LastWriteTime ? fi.CreationTime.ToString("MMMM yyyy") : wts;

            item.Tag = file.Key;
            item.Text = "" + (file.Key + 1) + ". " + (cts != wts ? cts + " - " + wts : wts);
            item.Checked = CurrentChat.ChatControl.HistoryPageIndex == file.Key;

            item.Click += (o, a) =>
            {
               CurrentChat.ChatControl.HistoryPageIndex = (int)(o as ToolStripMenuItem).Tag;
            };

            menuHistoryPages.Items.Add(item);
         }
      }
      private void menuContactGroup_Opening(object sender, CancelEventArgs e)
      {
         ContactGroup group = menuContactGroup.Tag as ContactGroup;

         if (group.IsSystem)
         {
            e.Cancel = true;
         }
         else
         {
            itemRemoveGroup.Visible = group.Owner.ServiceConfig.SupportsFeature(ServiceFeatures.RemoveGroup);
            itemCreateSubGroup.Visible = group.Owner.ServiceConfig.SupportsFeature(ServiceFeatures.AddSubgroup);
         }
      }
      private void menuContactPrivacy_Opening(object sender, CancelEventArgs e)
      {
         Contact contact = menuContactPrivacy.Tag as Contact;

         if (contact == null)
         {
            e.Cancel = true; return;
         }

         itemContactVipMode.Checked = contact.Owner.IsVipContact(contact.Identifier);
         itemBlockContact.Checked = contact.Owner.IsBlockedContact(contact.Identifier, PrivacyType.BlockMessage);
         itemVisibilityRuleBlock.Checked = contact.Owner.IsBlockedContact(contact.Identifier, PrivacyType.BlockVisibility);

         itemBlockContact.Text = Resources.S_Block_user.Replace("<user>", contact.CustomName);
         itemContactVipMode.Text = Resources.S_VIP_mode_for_user.Replace("<user>", contact.CustomName);
         itemVisibilityRuleBlock.Text = Resources.S_Hide_me_from_user.Replace("<user>", contact.CustomName);

         //itemContactVipMode.Visible = contact.Owner.ServiceConfig.SupportsFeature(ServiceFeatures.AllowList);
         itemVisibilityRuleBlock.Visible = contact.Owner.ServiceConfig.SupportsFeature(ServiceFeatures.BlockList);
      }

      private void itemAddParticipant_Click(object sender, EventArgs e)
      {
         MediaSession session = menuChatSession.Tag as MediaSession;

         FCommunicator.ShowMediaSession(session, TargetWindow.Existing);

         session.Visualizer.MediaWindow.ShowAddParticipant(session);
      }
      private void itemBlockParticipant_Click(object sender, EventArgs e)
      {
         MediaSession session = menuChatSession.Tag as MediaSession;

         ToolStripDropDownItem item = sender as ToolStripDropDownItem;

         Contact contact = item.Tag as Contact;
      }
      private void itemRemoveParticipant_Click(object sender, EventArgs e)
      {
         MediaSession session = menuChatSession.Tag as MediaSession;

         ToolStripDropDownItem item = sender as ToolStripDropDownItem;

         Contact contact = item.Tag as Contact;
      }
      private void itemSessionProperties_Click(object sender, EventArgs e)
      {
         MediaSession session = menuChatSession.Tag as MediaSession;

         FCommunicator.ShowMediaSession(session, TargetWindow.Existing);

         session.Visualizer.ShowStartPage(true);
      }
      private void itemAttachDetachSession_Click(object sender, EventArgs e)
      {
         MediaSession session = menuChatSession.Tag as MediaSession;

         FCommunicator.ShowMediaSession(session, session.Visualizer.MediaWindow.ExclusiveSessionMode ? TargetWindow.Default : TargetWindow.Blank);
      }
      private void itemShowStatusEvents_Click(object sender, EventArgs e)
      {
         ChatSession session = menuChatSession.Tag as ChatSession;

         session.ChatControl.ShowStatusEvents = !session.ChatControl.ShowStatusEvents;
      }
      private void itemCloseSession_Click(object sender, EventArgs e)
      {
         MediaSession session = menuChatSession.Tag as MediaSession;

         session.Close();
      }

      private void itemOpenChat_Click(object sender, EventArgs e)
      {
         FCommunicator.ShowChatSession(menuContact.Tag as Contact);
      }
      private void itemHistory_Click(object sender, EventArgs e)
      {
         FCommunicator.OpenChatSession(menuContact.Tag as Contact, true);
      }
      private void itemRemoveContact_Click(object sender, EventArgs e)
      {
         FCommunicator.ShowRemoveContact(menuContact.Tag as Contact);
      }
      private void itemContactProperties_Click(object sender, EventArgs e)
      {
         FCommunicator.ShowUserProperties(menuContact.Tag as Contact, null);
      }
      private void itemSetCustomName_Click(object sender, EventArgs e)
      {
         FCommunicator.ShowUserProperties(menuContact.Tag as Contact, "ContactOptions/CustomName");
      }
      private void itemContactSettings_Click(object sender, EventArgs e)
      {
         FCommunicator.ShowUserProperties((Contact)menuContactPrivacy.Tag, "ContactOptions");
      }
      private void itemCopyContactInfo_Click(object sender, EventArgs e)
      {
         try
         {
            Clipboard.SetText(menuContact.Tag.ToString());
         }
         catch (Exception)
         {
            //
         }
      }

      private void itemShowPage_Click(object sender, EventArgs e)
      {
         if (sender == itemLastMessages)
         {
            CurrentChat.ChatControl.ShowHistoryPage(-1, false, true);
         }
         else if (sender == itemNextPage)
         {
            CurrentChat.ChatControl.NextHistoryPage();
         }
         else if (sender == itemPrevPage)
         {
            CurrentChat.ChatControl.PrevHistoryPage();
         }
      }

      private void itemFindText_Click(object sender, EventArgs e)
      {
         if (CurrentChat.ChatControl.MediaWindow.TextSearchVisible)
         {
            string s = CurrentChat.ChatControl.MediaWindow.SearchString;
            if (s != "") CurrentChat.ChatControl.FindText(s, true);
         }
         else
         {
            CurrentChat.ChatControl.MediaWindow.ShowTextSearch(sender == itemFilterText);
         }
      }
      private void itemFilterUrls_Click(object sender, EventArgs e)
      {
         CurrentChat.ChatControl.ContentFilter = TextDataTypes.Url;
      }
      private void itemFilterEmails_Click(object sender, EventArgs e)
      {
         CurrentChat.ChatControl.ContentFilter = TextDataTypes.Email;
      }
      private void itemFilterDigits_Click(object sender, EventArgs e)
      {
         CurrentChat.ChatControl.ContentFilter = TextDataTypes.Digit;
      }
      private void itemFilterNumbers_Click(object sender, EventArgs e)
      {
         CurrentChat.ChatControl.ContentFilter = TextDataTypes.Number | TextDataTypes.Phone;
      }
      private void itemResetFilter_Click(object sender, EventArgs e)
      {
         CurrentChat.ChatControl.MediaWindow.HideTextSearch();
      }

      private void itemBlockContact_Click(object sender, EventArgs e)
      {
         Contact contact = (Contact)menuContact.Tag;
         ContactSettings settings = contact.Settings;

         settings.MessageRule = itemBlockContact.Checked == false ? PolicyRule.Block : PolicyRule.None;
         settings.InvitationRule = itemBlockContact.Checked == false ? PolicyRule.Block : PolicyRule.None;
         if (itemBlockContact.Checked == false) settings.VisibilityRule = PolicyRule.Block;

         FCommunicator.SetPermissions(contact.Owner, contact, settings.MessageRule, settings.InvitationRule, settings.VisibilityRule);
      }
      private void itemContactVipMode_Click(object sender, EventArgs e)
      {
         Contact contact = (Contact)menuContact.Tag;
         ContactSettings settings = contact.Settings;

         settings.VisibilityRule = itemContactVipMode.Checked == false ? PolicyRule.Allow : PolicyRule.None;
         settings.MessageRule = itemContactVipMode.Checked == false ? PolicyRule.Allow : PolicyRule.None;
         settings.InvitationRule = itemContactVipMode.Checked == false ? PolicyRule.Ask : PolicyRule.None;

         FCommunicator.SetPermissions(contact.Owner, contact, settings.MessageRule, settings.InvitationRule, settings.VisibilityRule);
      }
      private void itemVisibilityRuleBlock_Click(object sender, EventArgs e)
      {
         Contact contact = (Contact)menuContact.Tag;
         ContactSettings settings = contact.Settings;

         settings.VisibilityRule = itemVisibilityRuleBlock.Checked == false ? PolicyRule.Block : PolicyRule.None;
         settings.MessageRule = itemVisibilityRuleBlock.Checked == false ? PolicyRule.Ask : PolicyRule.None;
         settings.InvitationRule = itemVisibilityRuleBlock.Checked == false ? PolicyRule.Block : PolicyRule.None;

         FCommunicator.SetPermissions(contact.Owner, contact, settings.MessageRule, settings.InvitationRule, settings.VisibilityRule);
      }

      private void itemReplyMessage_Click(object sender, EventArgs e)
      {
         ServiceMessage message = menuMessage.Tag as ServiceMessage;

         if (message is ChatMessage)
         {
            message.MediaSession.Visualizer.MediaWindow.ComposeReply((ChatMessage)message, "");
         }
      }
      private void itemRepeatMessage_Click(object sender, EventArgs e)
      {
         ServiceMessage message = menuMessage.Tag as ServiceMessage;

         if (message is ChatMessage)
         {
            message.MediaSession.SendChatMessage(new ChatMessage(message.Text, message.MediaSession));
         }
      }
      private void itemAcceptInvitation_Click(object sender, EventArgs e)
      {
         FCommunicator.AcceptMediaSession((SessionInvitation)menuMessage.Tag);
      }
      private void itemDeclineInvitation_Click(object sender, EventArgs e)
      {
         SessionInvitation invitation = (SessionInvitation)menuMessage.Tag;

         FCommunicator.SendInvitationReply(new ServiceMessage(ServiceActions.SESSIONACK, null, invitation.OperationId,
                                   invitation.MediaSession.Account, invitation.Sender, -2, invitation.SessionGsid));
      }

      private void timerPresence_Tick(object sender, EventArgs e)
      {
         if (timerPresence.Interval > 1000) timerPresence.Interval = 1000;

         FCommunicator.TrackPresence();
      }
      private void trayControlMain_BalloonClick(object sender, EventArgs e)
      {
         if (Shell.FileDialogVisible) return;

         Exception error = FCommunicator.OperationError;

         FCommunicator.OperationError = null;

         if (error != null)
         {
            FCommunicator.ShowError("", error);
         }
         if ((string)trayControlMain.Tag == "updates")
         {
            trayControlMain.Tag = null;

            if (MessageBox.Show(Resources.S_app_will_now_exit_to_install_updates.Replace("<app>", FCommunicator.AppName),
                Resources.S_Updates.Replace("<product>", InternetCommunicator.AppInfo.ProductName), MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
               FCommunicator.Shutdown(false);
               Application.Restart();
            }
         }
      }
      private void trayControlMain_MouseClick(object sender, MouseEventArgs e)
      {
         if (Shell.FileDialogVisible) return;

         if (FCommunicator._MainWindow == null &&
             FCommunicator._LogonWindow != null &&
            !FCommunicator._LogonWindow.IsDisposed)
         {
            FCommunicator._LogonWindow.Show();
            FCommunicator._LogonWindow.Activate();
         }
         else if (FCommunicator._MainWindow != null)
         {
            if (e.Button == MouseButtons.Left)
            {
               if (Settings.Default.MainWindowLayout == WindowDockType.FloatPanel)
               {
                  FCommunicator._MainWindow.DoDockingAnimation(false);
               }
               else if (FCommunicator._MainWindow.Visible == false)
               {
                  FCommunicator._MainWindow.Visible = true;
               }
               FCommunicator._MainWindow.Activate();
            }
            else if (e.Button == MouseButtons.Right)
            {
               FCommunicator._MainWindow.Show();
               FCommunicator._MainWindow.Activate();
               MenuWrapper.ShowMenu(FCommunicator._MainWindow.menuMain);
            }
         }
      }
      private void trayControlMessage_BalloonHide(object sender, EventArgs e)
      {
         if (trayControlMessage.Tag is ChatMessage)
         {
            trayControlMessage.Tag = null;
            trayControlMessage.Hide();
         }
      }
      private void trayControlMessage_BalloonClick(object sender, EventArgs e)
      {
         if (Shell.FileDialogVisible) return;

         if (trayControlMessage.Tag is ChatMessage)
         {
            FCommunicator.MakeChatMessageIncoming(new MessagingOperationEventArgs(trayControlMessage.Tag as ChatMessage), null, true);
         }
         else if (FCommunicator.LastUnacceptedMessage is ChatMessage)
         {
            FCommunicator.AcceptMessage(FCommunicator.LastUnacceptedMessage);
         }
      }
      private void trayControlMessage_MouseClick(object sender, MouseEventArgs e)
      {
         if (Shell.FileDialogVisible) return;

         if (FCommunicator.LastUnacceptedMessage is ChatMessage)
         {
            if (e.Button == MouseButtons.Left)
            {
               if (FCommunicator.LastUnacceptedMessage != null) FCommunicator.AcceptMessage(FCommunicator.LastUnacceptedMessage);
            }
            else if (e.Button == MouseButtons.Right)
            {
               ChatMessage msg = FCommunicator.LastUnacceptedMessage as ChatMessage;

               trayControlMessage.Pause();
               trayControlMessage.SetBalloonTip(msg.Sender.CustomName, msg.Text.Substr(0, 50), ToolTipIcon.Info);
               trayControlMessage.ShowBalloonTip();
            }
         }
      }

      private void itemViewUserInfo_Click(object sender, EventArgs e)
      {
         User user = (User)menuUser.Tag;

         FCommunicator.ShowUserProperties(user, null);
      }
      private void itemSendMessage_Click(object sender, EventArgs e)
      {
         User user = (User)menuUser.Tag;

         Contact contact = FCommunicator.CurrentAccount.GetContact(user.Identifier);

         if (contact == null)
         {
            FCommunicator.AddContact(FCommunicator.CurrentAccount, user, null, true, "");
         }
         else
         {
            FCommunicator.OpenChatSession(contact, true);
         }
      }
      private void itemAddToContacts_Click(object sender, EventArgs e)
      {
         User user = (User)menuUser.Tag;

         if (!FCommunicator.CurrentAccount.IsContact(user.Identifier))
         {
            FCommunicator.ShowAddContact(user, false);
         }
         else
         {
            FCommunicator.ShowError(Resources.S_User_is_already_in_your_contact_list.Replace("<user>", user.ToString()), null);
         }
      }

      private void itemSetupUserpic_Click(object sender, EventArgs e)
      {
         if (FCommunicator.ShowUserpicDialog())
         {
            FCommunicator.CurrentAccount.ServiceDriver.SaveAccountData(FCommunicator.CurrentAccount, SaveAccountActions.UploadUserpic);
         }
      }
      private void itemResetUserpic_Click(object sender, EventArgs e)
      {
         FCommunicator.ResetUserpic(FCommunicator.CurrentAccount);
         FCommunicator.CurrentAccount.ServiceDriver.SaveAccountData(FCommunicator.CurrentAccount, SaveAccountActions.UploadUserpic);
      }
      private void itemChangePassword_Click(object sender, EventArgs e)
      {
         User user = (User)menuAccount.Tag;

         FCommunicator.ShowUserProperties(user, "Privacy/Password");
      }
      private void itemAccountPrivacy_Click(object sender, EventArgs e)
      {
         User user = (User)menuAccount.Tag;

         FCommunicator.ShowUserProperties(user, "Privacy");
      }
      private void itemAccountSettings_Click(object sender, EventArgs e)
      {
         User user = (User)menuAccount.Tag;

         FCommunicator.ShowUserProperties(user, "Settings");
      }
      private void itemAccountEditInfo_Click(object sender, EventArgs e)
      {
         User user = (User)menuAccount.Tag;

         FCommunicator.ShowUserProperties(user, "Info");
      }
      private void itemAccountSummary_Click(object sender, EventArgs e)
      {
         User user = (User)menuAccount.Tag;

         FCommunicator.ShowUserProperties(user, null);
      }

      private void itemGroupMessage_Click(object sender, EventArgs e)
      {
         //
      }
      private void itemRenameGroup_Click(object sender, EventArgs e)
      {
         FCommunicator.ShowRenameContactGroup((ContactGroup)menuContactGroup.Tag);
      }
      private void itemRemoveGroup_Click(object sender, EventArgs e)
      {
         FCommunicator.RemoveContactGroup((ContactGroup)menuContactGroup.Tag);
      }
      private void itemCreateSubGroup_Click(object sender, EventArgs e)
      {
         ContactGroup group = menuContactGroup.Tag as ContactGroup;

         FCommunicator.ShowAddContactGroup(group.Name, group.Owner);
      }

      private void timerUpdate_Tick(object sender, EventArgs e)
      {
         FCommunicator.CheckInstallation(CheckInstallationArg.Update, "");
      }
   }
}